//#pragma comment(linker,"/STACK:16777216") /*16Mb*/
//#pragma comment(linker,"/STACK:33554432") /*32Mb*/
#define _CRT_SECURE_NO_DEPRECATE
#include<sstream>
#include<iostream>
#include<numeric>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<memory>
#include<string>
#include<vector>
#include<cctype>
#include<list>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
using namespace std;

typedef unsigned long long      ui64;
typedef long long               i64;
typedef	vector<int>             VI;
typedef	vector<bool>            VB;
typedef	vector<VI>              VVI;
typedef	vector<string>          VS;
typedef	pair<int,int>           PII;
typedef map<string,int>         MSI;
typedef set<int>                SI;
typedef set<string>             SS;
typedef map<int,int>            MII;
typedef	pair<double,double>     PDD;

#define PB                      push_back
#define MP                      make_pair
#define X                       first
#define Y                       second
#define FOR(i, a, b)            for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b)           for(int i = (a) - 1; i >= (b); --i)
#define CLEAR(a, b)             memset(a, b, sizeof(a))
#define SZ(a)                   int((a).size())
#define ALL(a)                  (a).begin(), (a).end()
#define RALL(a)                 (a).rbegin(), (a).rend()
#define INF                     (2000000000)

#ifdef _DEBUG
#define eprintf(...) fprintf (stderr, __VA_ARGS__)
#else
#define eprintf(...) assert (true)
#endif

int main()
{
	int tests;
	cin >> tests;
	while(tests--) {
		int n,a,b,c,d;
		scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
		double SIDE = n;
		int k0 = 0;
		if( a==0 ) k0++;
		if( b==0 ) k0++;
		if( c==0 ) k0++;
		if( d==0 ) k0++;
		if( k0==4 ) {
			cout << "0\n";
			continue;
		}
		if( k0==3 ) {
			cout << "ambiguous\n";
			continue;
		}
		if( k0==2 ) {
			if( (a==0 && c==0) || (b==0 && d==0) )
				cout << "error\n";
			else
				cout << "ambiguous\n";
			continue;
		}
		if( k0==1 ) {
			if( a!=0 && c!=0 ) {
				double h = (a+c)*0.5;
				double side = max(0,a+c-max(b,d));
				if( side!=min(d,b) )
					cout << "error\n";
				else {
					double down = - (a+c-max(b,d) );
					double sd1 = fabs(SIDE - a*SIDE/(a+down));
					double sd2 = fabs(SIDE - c*SIDE/(c+down));
					double rest = sd1*sd2*down/6.0;
					printf("%.6lf\n", SIDE*SIDE*h + rest);
				}
				continue;
			}
			double h = (b+d)*0.5;
			double side = max(0,b+d-max(c,a));
			if( side!=min(a,c) )
				cout << "error\n";
			else {
				double down = - ( b+d-max(c,a) );
				double sd1 = fabs(SIDE - b*SIDE/(b+down));
				double sd2 = fabs(SIDE - d*SIDE/(d+down));
				double rest = sd1*sd2*down/6.0;
				printf("%.6lf\n", SIDE*SIDE*h + rest);
			}
			continue;
		}
		//k0==0
		double h = (a+c)*0.5;
		double side = max(0,a+c-b);
		if( side!=d )
			cout << "error\n";
		else
			printf("%.6lf\n", SIDE*SIDE*h);
		continue;
	}
    return 0;
}